﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Guid>" %>

<%@ Import Namespace="Tencent.OA.ACM.Entity" %>
<%@ Import Namespace="Tencent.OA.ACM.App" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">

    <script type="text/javascript">
        var ROUTE_TYPE = [];
        var VEHICLE = [];
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContainerPlaceHolder" runat="server">
    <div class="title" id="title_bar"></div>
    <div style="width: 650px; float: left;">
        <table class="tblData" cellpadding="0" cellspacing="0" style="width: 100%">
            <thead>
                <tr>
                    <th style="text-align: left;">
                        穿梭车辆类型说明
                    </th>
                </tr>
            </thead>
            <tr class="lt_head">
                <td>
                    <div id="remark_content" style="text-align: left; min-height: 200px;">
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="block_route_type" id="dv_routeTYpe">
        <div>
            温馨提示<br />
            您可以按 <b>CTRL+ F</b>进行查询。
            <div id="block_vehicle">
            </div>
        </div>
        <div class="block_route_section">
            <div class="block_city" id="all_routes">
                <a href="<%=this.Url.Content("~/StaffRoute/RoutePartion")%>">全部路线</a>
            </div>
        </div>
    </div>
    <div class="clear">
    </div>

    <script language="javascript">
        function loadJS() {
            var rtjsf = '<%=this.Url.Content("~/caches/base_info/routeType.js") %>';
            var vehiclejsf = '<%=this.Url.Content("~/caches/base_info/vehicle.js") %>';

            var rtjs = $.ajax({
                url: rtjsf + "?rd=" + Math.random(),
                async: false,
                dataType: "json"
            }).responseText;
            try {
                ROUTE_TYPE = eval("(" + rtjs + ")");
            } catch (ex) { ROUTE_TYPE = []; }

            var vehiclejs = $.ajax({
                url: vehiclejsf + "?rd=" + Math.random(),
                async: false,
                dataType: "json"
            }).responseText;
            try {
                VEHICLE = eval(vehiclejs);
            } catch (ex) { VEHICLE = []; }
        }

        $(document).ready(function() {
            loadJS();
            initVehicle();
            initType();
            setLinkStyle();
        });
        var cid = '<%=ViewData["CityID"] %>';
        var tid = '<%= ViewData["TypeID"]%>';
        function initType() {
            var dvType = $("#dv_routeTYpe");
            if (typeof (ROUTE_TYPE) != "undefined" && ROUTE_TYPE.length > 0) {
                var html = '';
                //城市循环
                $.each(ROUTE_TYPE, function(n, o) {
                    html = html + '<div class="block_route_section">';
                    html = html + '<div class="block_city">' + o.cityName + '</div>';
                    //班车类型循环
                    $.each(o.busType, function(m, b) {
                        html = html + '<div class="block_bus_type" cid="' + b.CityID + '" tid="' + b.BusTypeID + '">'
                                + '<a href="javascript:;" onclick=goToType("' + b.CityID + '","' + b.BusTypeID + '")>'
                                + b.BusTypeName
                                + '</a>'
                                + '</div>';
                    });
                    html = html + '</div>';
                })
                dvType.append(html);
            }
        }
        function initVehicle() {
            var dvVehicle = $("#block_vehicle");
            $.each(VEHICLE, function(n, o) {
                var html = '<span id="lk_' + o.veId + '"><a href="<%=this.Url.Content("~/StaffRoute/VehiclePartion?vId=")%>'
                          + o.veId
                          + '">'
                          + o.veName
                          + '</a></span><br/>';
                dvVehicle.append(html);
            });
        }
        function goToType(pcid, ptid) {
            if (pcid == cid && ptid == tid)
                return false;
            window.location = '<%=this.Url.Content("~/StaffRoute/RoutePartion")%>?cid='
                                + pcid
                                + '&tid='
                                + ptid;
        }
        function setLinkStyle() {
            var vId = '<%=this.Model %>';
            $.each(VEHICLE, function(n, o) {
                if (vId == o.veId) {
                    $("#title_bar").html(o.veName + '&nbsp;&nbsp;&nbsp;&nbsp;<a target=_blank href=<%= this.Url.Action("DownExcel","Home") %> style="float:none">【下载所有路线及站点】</a>');
                    $("#remark_content").html(o.veRemark.replace(/\n/g, "<br/>"));
                    $("#lk_" + o.veId).addClass("block_bus_type_cur");
                }
            });
        }
    </script>

</asp:Content>
